home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / lmwrap / ogl / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-11  |  3.6 KB  |  131 lines

  1. /*
  2.  * Copyright (c) 1995, Silicon Graphics, Inc.
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that the name of Silicon Graphics may not be used in any advertising or
  7.  * publicity relating to the software without the specific, prior written
  8.  * permission of Silicon Graphics.
  9.  *
  10.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
  11.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  12.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  13.  *
  14.  * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  15.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
  16.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE
  17.  * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN
  18.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19.  *
  20.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  21.  */
  22. /*----------------------------------------------------------------------------
  23.  *
  24.  * file   : main.c for openGL version of lmwrap
  25.  *
  26.  * Author : Yusuf Attarwala
  27.  * Date   : Apr 95
  28.  *
  29.  *---------------------------------------------------------------------------*/
  30. #include <sys/types.h>
  31. #include <malloc.h>
  32. #include <sys/stat.h>
  33. #include <fcntl.h>
  34. #include <math.h>
  35. #include <stdio.h>
  36. #include <string.h>
  37. #include <stdlib.h>
  38.  
  39. #define DEFINE_GLOBALS 1
  40. #include "globals.h"
  41. #undef DEFINE_GLOBALS
  42. #include <Xm/Protocols.h>
  43. #include <X11/StringDefs.h>
  44.  
  45. typedef struct _cmdLine {
  46.     String     complexity;           
  47. } CmdLine, *CmdLinePtr;
  48.  
  49. CmdLine commandLine;
  50.  
  51. static XtResource resources[] = {
  52.     {"complexity",    "Complexity",   XtRString,  sizeof(String),
  53.       XtOffset(CmdLinePtr,complexity), XtRString, "10",},
  54. };
  55.  
  56. static XrmOptionDescRec options[] = {
  57.     {"-c",      "complexity",  XrmoptionSepArg, NULL},
  58. };
  59.  
  60. static String fallbackResources[] = {
  61.     "*background:                  grey",
  62.     "*XmSeparator.traversalOn:     False",
  63.     "*XmLabel.traversalOn:         False",
  64.     "*fillOnSelect:                True",
  65.     "*selectColor:                 yellow",
  66.     "*ui*fontList:                 -adobe-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*",
  67.     "*gizmo*fontList:              -adobe-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*",
  68.     NULL
  69. };
  70.  
  71. /* function declaration */
  72. void main();
  73.  
  74.  
  75. void
  76. printDescription()
  77. {
  78.     printf("\n openGL version of lmwrap\n\n");
  79. }
  80.  
  81. void
  82. main(argc,argv)
  83. int argc;
  84. char **argv;
  85. {
  86.     Atom xaWmDeleteWindow;
  87.     void doExit();
  88.  
  89.     toplevel = XtAppInitialize(&appContext,"LmOGL",
  90.                                options,XtNumber(options),
  91.                                &argc,argv,
  92.                                fallbackResources,
  93.                                (ArgList)NULL, 0);
  94.  
  95.  
  96.     display  = XtDisplay(toplevel);
  97.     screen   = XDefaultScreen(display);
  98.     XtGetApplicationResources(toplevel,&commandLine,
  99.                               resources,XtNumber(resources),
  100.                               NULL,0);
  101.  
  102.  
  103.     XtVaSetValues(toplevel,XmNtitle,"lmwrap - Open GL",
  104.                            XmNiconName,"lmwrapO",
  105.                            XmNdeleteResponse, XmDO_NOTHING,
  106.                            NULL);
  107.  
  108.     xaWmDeleteWindow = XmInternAtom(display,"WM_DELETE_WINDOW",TRUE);
  109.     XmAddWMProtocolCallback(toplevel,xaWmDeleteWindow,doExit,0);
  110.  
  111.  
  112.  
  113.     initGlobals();
  114.  
  115.     createMenus(toplevel);
  116.     XtRealizeWidget(toplevel);
  117.  
  118.     createGraphics(toplevel);
  119.     drawScene();
  120.     XFlush(display);
  121.  
  122.     XtAppMainLoop(appContext);
  123. }
  124.  
  125. void
  126. doExit()
  127. {
  128.     exit(0);
  129. }
  130.  
  131.